package interfaces;

import java.util.Date;
import java.util.Vector;

import domain.items.Post;

public interface SearchEngine {

	/**
	 *
	 * @param authorName
	 * @return vector of posts
	 */
	public Vector<Post> searchByAuthor(String authorName);

	/**
	 *
	 * @param from
	 * @param to
	 * @return vector of posts
	 */
	public Vector<Post> searchByDate(Date from, Date to);

	/**
	 *
	 * @param sentence
	 * @return vector of posts
	 */
	public Vector<Post> searchByContent(String sentence);

	
	/**
	 * each time a post is added/edited/deleted, this method needs to be invoked, 
	 * and it updates the search engine DataBase
	 * HOW TO USE - 
	 * 1) NEW post is added - the new post goes into 'newPost', oldPost = null.
	 * 2) DELETE post - the post that is being deleted goes to 'oldPost', newPost = null.
	 * 3) UPDATE post - the original post before changes goes to 'oldPost', 
	 * 					the new post after the change goes to 'newPost'.
	 * ADVICE ABOUT UPDATE POST - if i'm not mistaken, when updating a post p, we just change
	 * 		the value of the fields in p. in order to "keep" the old post, which is needed to invoke
	 * 		this method, do something like this :
	 * 		Post copy = p.clone();
	 * 		p.setContent("new content of the post");
	 * 		searchEngine.updateSearchDB(p, copy);
	 * the clone() method in post was implemented by me (shai)
	 * if you have any questions - call me!
	 * @param newPost
	 * @param oldPost
	 */
	public void updateSearchDB(Post newPost, Post oldPost);
}
